package api

import (
	"github.com/gin-gonic/gin"
	jwt2 "github.com/golangblogs/gojwt"
	"month/api/handler"
	"month/api/middleware"
	"month/consts"
)

func LoadRoutes(r *gin.Engine) {
	r.Use(middleware.RESTMiddleware())
	api := r.Group("/api")
	{
		user := api.Group("/user") // todo: 用户模块
		{
			user.POST("/createUser", handler.CreateUser) //用户注册
			user.POST("/loginUser", handler.LoginUser)   //用户登录
		}
		reviewer := api.Group("/reviewer") // 审核人员列表
		{
			reviewer.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			reviewer.POST("/listReviewer", handler.ListReviewer)
		}
		video := api.Group("/video")
		{
			video.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			video.POST("/addVideo", handler.AddVideo)                 //上传视频
			video.POST("/createVideo", handler.CreateVideo)           //添加视频
			video.POST("/updatedVideo", handler.UpdatedVideo)         //视频更新
			video.POST("/updateVideo", handler.UpdateVideo)           //视频审核
			video.POST("/deleteVideo", handler.DeleteVideo)           //视频删除
			video.POST("/queryVideo", handler.QueryVideo)             //视频详情
			video.POST("/listVideo", handler.ListVideo)               //视频列表
			video.POST("/castOneVideo", handler.CastOneVideo)         //一级查询
			video.POST("/castTwoVideo", handler.CastTwoVideo)         //二级查询
			video.POST("/statusVideo", handler.StatusVideo)           //审核状态查询
			video.POST("/nameVideo", handler.NameVideo)               //视频名称查询
			video.POST("/founderNumVideo", handler.FounderNumVideo)   //创建人工号查询
			video.POST("/userNumVideo", handler.UserNumVideo)         //作者工号查询
			video.POST("/reviewerNumVideo", handler.ReviewerNumVideo) //审核人工号查询
			video.POST("/keywordsVideo", handler.KeywordsVideo)       //关键字查询
		}
		chat := api.Group("/chat")
		{
			chat.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			chat.GET("/chat", handler.Chat)
			chat.POST("/anyChat", handler.AnyChat) //提醒消息
		}
	}
}
